package StudyCode.summary.mycollection;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReturnsTheMaximumOfAnArray {
	public static void main(String[] argv) {
		double[] v = new double[]{34.45, 35.45, 36.67, 37.78, 37.0000,
				37.1234, 67.2344, 68.34534, 69.87700};
		System.out.println("数组的最大值:" + max(v));
	}

	public static double max(double[] v) {
		double max = v[0];
		for (int i = 1; i < v.length; i++) {
			if (max < v[i]) {
				max = v[i];
			}
		}
		return (max);
	}


	public static double max(double[][] v) {
		double max = max(v[0]);
		for (int i = 1; i < v.length; i++) {
			if (max < max(v[i])) {
				max = max(v[i]);
			}
		}
		return (max);
	}


	public static int max(int[] v) {
		int max = v[0];
		for (int i = 1; i < v.length; i++) {
			if (max < v[i]) {
				max = v[i];
			}
		}
		return (max);
	}


	public static int max(int[][] v) {
		int max = max(v[0]);
		for (int i = 1; i < v.length; i++) {
			if (max < max(v[i])) {
				max = max(v[i]);
			}
		}
		return (max);
	}
}
